<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"> 

    <h:form>
        <input type="submit" class="button" value="Novo" jsf:action="${musicianManagedBean.openNew}" jsf:id="novo"/>
        <br/>
        <br/>
        <fieldset>
            <legend> Consulta de Músicos </legend>
            <div class="messagesContainer"><h:messages warnClass="warnMessages" class="messages"/></div>
            <f:view>
                <h:panelGroup rendered="${not empty musicianManagedBean.list}">
                    <table class="tableConsulta">    
                        <thead>
                            <tr>
                                <td>
                                    Nome Artístico
                                </td>                               
                                <td>
                                    Origem
                                </td>
                                <td>
                                    Data de nascimento  
                                </td>                        
                                <td>
                                    Editar
                                </td>                        
                                <td>
                                    Excluir 
                                </td>                        
                            </tr>
                        </thead>   
                        <tbody>
                            <ui:repeat value="${musicianManagedBean.list}" var="musician">
                                <tr>
                                    <td>
                                        ${musician.name}
                                    </td>                                 
                                    <td>
                                        ${musician.originCity.name}
                                    </td>
                                    <td>
                                        <label jsf:value="${musician.birthday}"   >
                                            <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-0"/>
                                        </label>
                                    </td>
                                    <td>
                                        <input type="submit" class="buttonEdit" value="" jsf:action="${musicianManagedBean.openToUpdate}" jsf:id="editar">
                                <f:param value="${musician.id}" name="id"/>
                                </input>
                                </td>
                                <td>
                                    <input type="submit" value="" class="buttonDelete" jsf:action="${musicianManagedBean.delete}" jsf:id="deletar">
                                <f:param value="${musician.id}" name="id"/>
                                </input>
                                </td>
                                </tr>                       
                            </ui:repeat>
                        </tbody>
                    </table>
                </h:panelGroup>
                <h:panelGroup rendered="${empty musicianManagedBean.list}">
                    <br/>Ainda não há músicos cadastrados.
                </h:panelGroup>             
            </f:view>
        </fieldset> 
    </h:form>

</html>

